import express from "express"
const app = express()

// 后端解决跨域问题
app.use((req, res, next) => {
    // 允许所有来源
    res.header('Access-Control-Allow-Origin', '*')
    // 允许所有请求方式
    res.header('Access-Control-Allow-Methods', 'PUT,POST,GET,DELETE,OPTIONS')
    // 放行
    next()
})

app.get('/hello', (req, res) => {
    res.json({
        code: 200,
        msg: 'hello world'
    })
})

app.listen(5000, () => {
    console.log('http://localhost:5000')
})